<cfcomponent extends="org.coldquery.ColdQuery">
  <cfset _i= structNew() />
  <cfset _i.loaded=false />
  <cfset _i.loader=false />
  <cfset _i.cachetimeSeconds=false />

  <cfset _i.items = arrayNew(1) />
  <cfset _i.lastResult = "" />

  <cffunction name="init" output="false">
    <cfargument name="queryloader" required="true">
    <cfset setLoader(arguments.queryLoader) />
    <cfset super.init(ArrayNew(1)) /><!--- give it an empty array --->
    <cfreturn this />
  </cffunction>

  <cffunction name="getItems" access="public" returnType="array" output="false">
    <cfif !isLoaded() OR getCacheTimeSeconds() LT ((getTickCount()/1000)-getTimeLoadedSeconds())>
      <cfset super.init(getLoader().load()) />
      <cfset setLoaded() />
    </cfif>
    <cfreturn super.getItems() />
  </cffunction>

  <cffunction name="isLoaded" access="private" returnType="boolean" output="false">
    <cfreturn _i.loaded />
  </cffunction>

  <cffunction name="setLoaded" access="private" output="false">
    <cfset setTimeLoadedSeconds(getTickCount()/1000)>
    <cfset _i.loaded=true />
  </cffunction>

  <cffunction name="getLoader" access="private" output="false" >
    <cfreturn _i.loader />
  </cffunction>

  <cffunction name="setLoader" access="private" output="false">
    <cfargument name="value" required="true">
    <cfset _i.loader = arguments.value />
  </cffunction>

  <cffunction name="getCacheTimeSeconds" access="private" output="false" returntype="numeric">
    <cfreturn _i.cachetimeSeconds />
  </cffunction>

  <cffunction name="setCacheTimeSeconds" access="private" output="false">
    <cfargument name="value" required="true" type="Numeric">
    <cfset _i.cachetimeSeconds=arguments.value />
  </cffunction>

  <cffunction name="getTimeLoadedSeconds" access="private" output="false" returntype="numeric">
    <cfreturn _i.cachetimeSeconds />
  </cffunction>

  <cffunction name="setTimeLoadedSeconds" access="private" output="false">
    <cfargument name="value" required="true" type="Numeric">
    <cfset _i.timeLoadedSeconds=arguments.value />
  </cffunction>

  <cffunction name="getLength" access="public" output="false">
    <cfreturn getLoader().getSize() />
  </cffunction>


</cfcomponent>